import glob

from PIL import Image
fs='/mnt/d/datasets/sex_and_age/age/train/images/*.jpg'
# im = Image.open(fs)
# print(im.format,im.size,im.mode)

f = glob.glob(fs)
for fs in f:
    im = Image.open(fs)
    if im.format != "JPEG":
        print(fs)
        print(im.format, im.size, im.mode)
        # im.convert("RGB")

